package com.eudon.design_pattern.behavioral.state.state;

import java.util.HashMap;
import java.util.Map;

/**
 * @author eudon
 * @description 马里奥状态机
 * @date 2025/9/3
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class MarioStateMachine {
    private Map<Class<? extends IMarioState>, IMarioState> stateMap = new HashMap<>();
    private IMarioState marioState;
    private int score;

    public MarioStateMachine() {
        this.score = 0;
    }

    public void init() {
        stateMap.put(SmallMario.class, new SmallMario(this));
        stateMap.put(SuperMario.class, new SuperMario(this));
        stateMap.put(FireMario.class, new FireMario(this));
        stateMap.put(CapeMario.class, new CapeMario(this));
        marioState = stateMap.get(SmallMario.class);
    }

    public void getMushRoom() {
        marioState.getMushRoom();
    }

    public void getFire() {
        marioState.getFire();
    }

    public void meetMonster() {
        marioState.meetMonster();
    }

    public void getCape() {
        marioState.getCape();
    }

    public String getStateName() {
        return marioState.getName();
    }

    public void setMarioState(Class<? extends IMarioState> state) {
        this.marioState = stateMap.get(state);
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

}
